<?php
/**
 * com_easiv2
 * 
 * @author Lukas Gruber, Internet Technology Kapfenberg, FH JOANNEUN
 * @copyright 2011, Lukas Gruber, Internet Technology Kapfenberg, FH JOANNEUM
 * @license GNU/GPLv3 - http://www.gnu.org/licenses/gpl-3.0.html
 * @contact lukasgruber@gmx.net
 * @website http://www.lukasg255.bplaced.net
 */

	$db = JFactory::getDBO();
	$idsToEdit = JRequest::getVar('cid');

	foreach($idsToEdit as $id) {
		$db->setQuery("SELECT * FROM #__easiv2_instances WHERE id='".$id."'");
		$instance = $db->loadObject();
		
		/*
		 * Set values displayed in the text inputs
		 */
		if(($name = JRequest::getVar($id.'_name')) == "") {
			$name = $instance->name;
		}
		
		if(($http = JRequest::getVar($id.'_http')) == "") {
			$http = $instance->http_address;
		}
		
		if(($ftp = JRequest::getVar($id.'_ftp')) == "") {
			$ftp = $instance->ftp_host;
		}
		
		if(($port = JRequest::getVar($id.'_port')) == "") {
			$port = $instance->port;
		}
		
		if(($folder = JRequest::getVar($id.'_folder')) == "") {
			$folder = $instance->host_folder;
		}
		
		if(($user = JRequest::getVar($id.'_user')) == "") {
			$user = $instance->ftp_user;
		}
		
		echo "<tr>";
			echo "<td style=\"background-color:#00FF99; color:#000; font-weight:bold;\">".JText::_('COM_EASIV2_GENERAL_ID')."</td><td style=\"background-color:#00FF99; color:#000; font-weight:bold;\"><input type=\"hidden\" name=\"id[]\" value=\"".$id."\" />".$id."</td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_NAME')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_name\" value=\"".$name."\" />";
		echo "<tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_HTTPADDRESS')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_http\" value=\"".$http."\" />";
		echo "<tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_FTPHOST')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_ftp\" value=\"".$ftp."\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_FTPPORT')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_port\" value=\"".$port."\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_FTPHOSTFOLDER')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_folder\" value=\"".$folder."\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_GENERAL_FTPUSERNAME')."</td><td><input type=\"text\" style=\"width:100%;\" name=\"".$id."_user\" value=\"".$user."\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_EDITINSTANCES_VIEW_DEFAULTBODY_NEWFTPPASSWORD')."</td><td><input type=\"password\" style=\"width:100%;\" name=\"".$id."_pass\"  value=\"\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_EDITINSTANCES_VIEW_DEFAULTBODY_CURRENTIDENTIFIER')."</td><td><input type=\"password\" style=\"width:100%;\" name=\"".$id."_current_identifier\"  value=\"\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_EDITINSTANCES_VIEW_DEFAULTBODY_NEWIDENTIFIER')."</td><td><input type=\"password\" style=\"width:100%;\" name=\"".$id."_new_identifier\"  value=\"\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo "<td>".JText::_('COM_EASIV2_EDITINSTANCES_VIEW_DEFAULTBODY_RETYPEIDENTIFIER')."</td><td><input type=\"password\" style=\"width:100%;\" name=\"".$id."_new_identifier2\"  value=\"\" /></td>";
		echo "</tr>";
		echo "<tr>";
			echo"<td colspan=\"2\"><hr><input type=\"hidden\" name=\"cid[]\" value=\"".$id."\" /></td>";
		echo "</tr>";
	}
?>